package cn.manyufun.myf.ui.main.presenter;

import cn.manyufun.myf.R;
import cn.manyufun.myf.bean.SearchBean;
import cn.manyufun.myf.common.baserx.RxSubscriber;
import cn.manyufun.myf.ui.main.contract.SearchContract;

/**
 * Created by Xiao on 2018-02-03.
 */

public class SearchPresenter extends SearchContract.Presenter {
    @Override
    public void loadSearchRequest(int pageIndex, int pageSize, String keyword) {
        mRxManage.add(mModel.search(pageIndex, pageSize, keyword)
                .subscribe(new RxSubscriber<SearchBean>(mContext, false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                        mView.showLoading(mContext.getString(R.string.loading));
                    }

                    @Override
                    protected void _onNext(SearchBean followListBean) {
                        mView.returnSearchResult(followListBean);
                        mView.stopLoading();
                    }

                    @Override
                    protected void _onError(String message) {
                        mView.showErrorTip(message);
                    }
                }));
    }
}
